package com.api.shopapi.service.impl;

import com.api.shopapi.entity.GoodsColor;
import com.api.shopapi.mapper.GoodsColorMapper;
import com.api.shopapi.service.GoodsColorService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("GoodsColorServiceImplOne")
public class GoodsColorServiceImpl implements GoodsColorService {

    @Autowired
    private GoodsColorMapper goodsColorMapper;

    @Override
    public int insert(GoodsColor goodsColor) {
        return goodsColorMapper.insert(goodsColor);
    }

    @Override
    public int delete(String goodsColorCode) {
        return goodsColorMapper.delete(goodsColorCode);
    }

    @Override
    public int update(GoodsColor goodsColor) {
        return goodsColorMapper.update(goodsColor);
    }

    @Override
    public GoodsColor getByGoodsColorCode(String goodsColorCode) {
        return goodsColorMapper.getByGoodsColorCode(goodsColorCode);
    }

    @Override
    public List<GoodsColor> getList() {
        return goodsColorMapper.getList();
    }

    @Override
    public PageInfo<GoodsColor> getPageList(int pageIndex,int pageSize,String name, int status) {
        PageHelper.startPage(pageIndex,pageSize);
        List<GoodsColor> goodsColorList = goodsColorMapper.getPageList(name, status);
        PageInfo<GoodsColor> goodsColorPageInfo=new PageInfo<>(goodsColorList);
        return goodsColorPageInfo;
    }
}
